<%@page import="java.text.Format"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="firstping.model.SaveDomain"%>
<%@page import="firstping.model.Domain"%>
<%@page import="java.util.List"%>
<%@page import="firstping.model.Customer"%>
<%
	String title = (String) request.getAttribute("title");
	String dayOne = (String) request.getAttribute("dayOne");
	String timeOne = (String) request.getAttribute("timeOne");
	String dayTwo = (String) request.getAttribute("dayTwo");
	String timeTwo = (String) request.getAttribute("timeTwo");
	String description = (String) request.getAttribute("description");
	String keywords = (String) request.getAttribute("keyword");

	String site = (String) request.getAttribute("site");
	String customer = (String) session.getAttribute("customer");
	List<SaveDomain> domains = (List<SaveDomain>) request
			.getAttribute("list");
%>
<jsp:include page="layout/header.jsp">
	<jsp:param name="title" value="<%=title %>" />
	<jsp:param name="description" value="<%=description %>" />
	<jsp:param name="keywords" value="<%=keywords %>" />
</jsp:include>
<div id="mainpage">
	<div id="maincontent">
		<h1>
			View Website : <span class="website"><%=site %></span>
		</h1>

		<div class="box-wrapper">
			<div class="web-result">
				<table class="table-style style-colorstripes">
					<thead>
						<tr>
							<th>#</th>
							<th class="highlight">Status</th>
							<th>Time</th>
						</tr>
					</thead>
					<tbody>
						<%
							for (int i = 0; i < domains.size(); i++) {
						%>
						<tr class="<%=(i%2==0)?"odd":"" %>">
							<td><%=(i + 1)%></td>
							<td class="highlight"><%=(domains.get(i).getStatus().equals("False")) ? "<img src='/images/error.png' alt='false' />"
						: "<img src='/images/tick.png' alt='true' />" %>
							</td>
							<td>
								<%
									Format formatter = new SimpleDateFormat("MM/dd/yy h:m:s");
										String s = formatter.format(new Date(Long.parseLong(domains
												.get(i).getLongDate())));
										out.print(s);
								%>
							</td>
						</tr>
						<%
							}
						%>
					</tbody>
				</table>
			</div>
			<div class="web-search">
				<form method="post" action="/view/<%=site.replaceAll("http://", "")%>">
					<h3 style='color:#B92B0F'>Server time : <%
					Format formatter;
					formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					out.print(formatter.format(new Date()));
				%></h3>
					<div>
						<span>From (y-m-d h:m:s) : </span>  					
						<input id='from' type="text" name="day_from" value="<%=(dayOne != null)?dayOne:""%>"/>
						<input name="time_from" type="text" value="<%=(timeOne != null)?timeOne:"00:00:00"%>" onclick="javascript:this.value=''"/>
					</div>
					<div>
						<span>To (y-m-d h:m:s) : </span>					
						<input id='to' type="text" name="day_to" value="<%=(dayTwo != null)?dayTwo:""%>"/>
						<input name="time_to" type="text" value="<%=(timeTwo != null)?timeTwo:"00:00:00"%>" onclick="javascript:this.value=''"/>
					</div>
					<input name="name" type="hidden"
						value="<%=site.replaceAll("http://", "")%>" />
					<button type="submit" class="button-style">Search</button>			
				</form>
			</div>
			<div class="clearbreak"></div>
		</div>
	</div>
</div>
<link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.8.16.custom.css" />	
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" >
$(function() {
	var dates = $( "#from, #to" ).datepicker({
		defaultDate: "+1w",
		changeMonth: true,
		numberOfMonths: 2,
		onSelect: function( selectedDate ) {
			var option = this.id == "from" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" ),
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
	});
	$( "#from" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
	$( "#to" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
});
</script>
<jsp:include page="/layout/footer.jsp">
	<jsp:param name="language" value="1" />
</jsp:include>
